<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>确认订单</title>
    <script src="__INDEX__/js/mui.min.js"></script>
    <link href="__INDEX__/css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
    <link rel="stylesheet" href="__INDEX__/css/style.css" />
    <link rel="stylesheet" href="__INDEX__/css/yund.css" />
</head>
<body>
	<header class="mui-bar mui-bar-nav">
	    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
	    <h1 class="mui-title">确认订单</h1>
	</header>
	<nav class="mui-bar mui-bar-tab pay_bar_tab">
	    <a class="mui-tab-item left">合计：<em>¥</em><em id='heji'>{$goods_info['cost_price']}</em></a>
	    <a class="mui-tab-item right" onclick="confirm_pay()">确定付款</a>
	</nav>
	<div class="mui-content">
		<form class="mui-input-group layui-form" id='my_form' method="post" action="{:url('shop/order_buy')}">
	    <input class="mui-input-numbox" name='address_id' type="hidden" value="{$user_address['id']}"/>
	    <input class="mui-input-numbox" name='goods_id' type="hidden" value="{$goods_info['goods_id']}"/>
	    <div class="pay_address">
	    	<a href="{:url('member/address')}">
	    		<p class="clearfix">
	    			<span class="pay_addr_name">{$user_address['consignee']}</span>
	    			<span class="pay_addr_call">{$user_address['mobile']}</span>
	    		</p>
	    		<p class="pay_addrinfo">{$user_address['address']}</p>
	    	</a>
	    </div>
	    <div class="pay_ordinfo">
	    	<p class="pay_ord_dpmc"><span class="iconfont icon-shangcheng"></span>{$goods_info['agent_name']}</p>
	    	<ul class="pay_ord_list qqdd_list">
	    		<li>
	    			<div class="pay_ord_sp clearfix">
			    		<div class="pay_sp_img"><img src="{$goods_info['logo']}"></div>
			    		<div class="pay_sp_info">
			    			<p class="pay_spnam">{$goods_info['goods_name']}</p>
			    			<p class="pay_sppribox clearfix">
			    				<span class="pay_sppri">¥<em id='goods_price' style="color: #FF0000;text-decoration:unset;font-size: 18px;">{$goods_info['cost_price']}</em><em>{$goods_info['sale_price']}</em></span>
			    				<span class="pay_spnum">X<em id='goodsx_num'>1</em></span>
			    			</p>
			    		</div>
			    	</div>
			    	<div class="pay_ord_num clearfix">
			    		<span>购买数量</span>
			    		<div class="mui-numbox" data-numbox-min='1'>
							<button class="mui-btn mui-btn-numbox-minus" type="button" onclick="account(1)">-</button>
							<input class="mui-input-numbox" name="goods_num" type="number" />
							<button class="mui-btn mui-btn-numbox-plus" type="button" onclick="account(2)">+</button>
						</div>
			    	</div>
	    		</li>
	    	</ul>
	    	<div class="layui-form-item">
			    <label class="layui-form-label" style="width: 19%;">配送方式：</label>
			    <div class="layui-input-block" style="text-align: center;">
			    	{if $goods_info['express_type'] == 1}
		    			<input type="radio" name="express_type" value="1" title="快递免邮" checked>
		    		{elseif $goods_info['express_type'] == 2}
		    			<input type="radio" name="express_type" value="2" title="到店自取" checked>
		    		{else}
			    		<input type="radio" name="express_type" value="1" title="快递">
				    	<input type="radio" name="express_type" value="2" title="到店自取" checked>
		    		{/if}
			    </div>
			</div>
	    	<div class="pay_ord_liuy">
	    		<label>买家留言:</label>
	    		<input type="text" name="memo" placeholder="选填（对本次交易的说明）"></input>
	    	</div>
	    	<div class="pay_ord_zj">
	    		<span>共<em id='goods_num'>1</em>件商品</span>
	    		<span>小计：<em>¥</em><em id='xiaoji'>{$goods_info['cost_price']}</em></span>
	    	</div>
	    <!--<div class="pay_paystyle" style="height: 45px;background-color: #fff;margin-bottom: 55px;">
			<div class=" mui-checkbox"><!--'支付方式1现金2微信3支付宝4银联'
				<label style="float: left;font-size: 18px;margin-right: 56%;width: 35%;">小卡支付</label>
				<input name="pay_type" value="2" type="checkbox" checked >
			</div>
		</div>-->
		</div>
</form>
</div>
</body>
</html>
{include file="public/footer" /}
<script>
	/**合计
	 * @param  symbol :1减，2加
	 */
	function account(symbol){
		//获取商品价格
		var goods_price = $('#goods_price').text();
		var total_money = parseInt(goods_price)  + parseInt($('#xiaoji').text());
		var goodsx_num = parseInt($('#goodsx_num').text())  + 1;
		var goods_num = parseInt($('#goods_num').text())  + 1;
		
		if(symbol == 1){
			total_money = parseInt($('#xiaoji').text()) - parseInt(goods_price);
			goodsx_num = parseInt($('#goodsx_num').text())  - 1;
			goods_num = parseInt($('#goods_num').text())  - 1;
			
		}
		$('#xiaoji').text(total_money);
		$('#heji').text(total_money);
		$('#goodsx_num').text(goodsx_num);
		$('#goods_num').text(goods_num);
	}
	
	function confirm_pay(){
		layer.confirm('您确定付款？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				type:"post",
				url: "{:url('shop/order_buy')}",
				data: $('#my_form').serialize(),//表单数据
				success: function(data) {
					layer.msg(data.msg, {
					  icon: 1,
					  time: 1500 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						  if(data.code == 200) {
								location.href = data.url
						  }
					}); 
				}
			})
		})
	}
	
</script>